package com.nut.lmsc.api.sys;

import com.nut.lmsc.api.req.PrepayReq;
import com.nut.lmsc.common.Result;
import com.nut.lmsc.jbb.JbbMsgService;
import com.nut.lmsc.jbb.JbbService;
import com.nut.lmsc.util.IdUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@Slf4j
@RestController
@RequestMapping("/jbb")
public class JbbController {

    @Autowired
    private JbbMsgService jbbMsgService;

    @Autowired
    private JbbService jbbService;

    @GetMapping("/test")
    public Result test() {
        return Result.ok();
    }

    @GetMapping("/processRecord")
    public Result processRecord(@RequestParam Integer id) {
        jbbMsgService.processRecord(id);
        return Result.ok();
    }

    @PostMapping("/callback")
    public Result callback(@RequestParam(required = false) String message) {
        log.info("jbb_callback=" + message);
        jbbMsgService.process(message);
        return Result.ok();
    }

    @GetMapping("/pay")
    public void pay(HttpServletResponse response) {

        PrepayReq req = new PrepayReq();
        req.setOrderNo(IdUtil.generateSsn());
        req.setPayMoney(1);
        req.setPayWay(1);
        req.setBody("ee2");
        req.setBizNo("123");

        jbbService.payPrepay(req);

    }

//    {
//        "bizNo": "24100910002",
//            "object": "corpMember",
//            "auditDesc": "great",
//            "createdTime": "2024-09-09",
//            "settleAccountId": "eee",
//            "status": "SUCCEEDED"
//    }

}